﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using System.IO;

namespace Gemciler_Uretim.SISTEM
{
    public partial class MesajBilgisi : DevExpress.XtraEditors.XtraForm
    {
        public MesajBilgisi()
        {
            InitializeComponent();
        }
        public int aktif_kullanici;
        string secilen_versiyon,sorgu_ilk = "SELECT  TOP 1 tarih AS [TARİH], versiyon  AS  [  VERSİYON NO  ]  from TK_VERSIYON_BILGILERI  GROUP BY tarih,versiyon ORDER BY  tarih  DESC", sorgu = "";
        SqlConnecitonClass sqlbaglanti = new SqlConnecitonClass();
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void YeniVersiyonBilgisi_Load(object sender, EventArgs e)
        {
            sorgu = sorgu_ilk;
            _1_dgv_guncelle();
            int index1 = 0;
            secilen_versiyon = "" + gridView1.GetRowCellValue(index1, "  VERSİYON NO  ").ToString() + "";
            _2_dgv_guncelle();

        }
        private void _1_dgv_guncelle()
        {
            gridControl1.DataSource = null;
            gridView1.Columns.Clear();
            // ---sip_special1='O' VEYA '' ONAY BEKLİYOR 
            gridControl1.DataSource = sqlbaglanti.ShowTable(""+sorgu+"", CommandType.Text);
            this.gridControl1.TabIndex = 0;
            this.gridView1.OptionsBehavior.AllowIncrementalSearch = false;
            this.gridView1.OptionsView.ShowAutoFilterRow = false;
            this.gridView1.OptionsView.ShowGroupPanel = false; // gruplama alanı
            this.gridView1.OptionsBehavior.Editable = false;

            //this.gridView1.OptionsBehavior.ReadOnly = false;
            this.gridView1.OptionsView.ShowFooter = true;
            gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            this.gridView1.ColumnPanelRowHeight = 55;
    
            gridView1.OptionsView.HeaderFilterButtonShowMode = FilterButtonShowMode.Button;
            gridView1.BestFitColumns();

        }
        private void _2_dgv_guncelle()
        {
            gridControl2.DataSource = null;
            gridView2.Columns.Clear();
            // ---sip_special1='O' VEYA '' ONAY BEKLİYOR 
            gridControl2.DataSource = sqlbaglanti.ShowTable("SELECT versiyon_mesaj AS [VERSİYON AÇIKLAMALARI]  FROM TK_VERSIYON_BILGILERI WHERE versiyon='"+secilen_versiyon+"'", CommandType.Text);
            this.gridControl2.TabIndex = 0;
            this.gridView2.OptionsBehavior.AllowIncrementalSearch = false;
            this.gridView2.OptionsView.ShowAutoFilterRow = false;
            this.gridView2.OptionsView.ShowGroupPanel = false; // gruplama alanı
            this.gridView2.OptionsBehavior.Editable = false;

            //this.gridView1.OptionsBehavior.ReadOnly = false;
            this.gridView2.OptionsView.ShowFooter = true;
            gridView2.OptionsView.ColumnAutoWidth = false;
            this.gridView2.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            this.gridView2.ColumnPanelRowHeight = 55;
          
            gridView2.OptionsView.HeaderFilterButtonShowMode = FilterButtonShowMode.Button;
            gridView2.BestFitColumns();

        }

        private void checkEdit1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkEdit1.Checked == false)
            {
                sqlbaglanti.CommScalar("UPDATE  TK_KULLANICI_TANIMLARI  SET ku_giris_mesaj=1 WHERE ku_kodu=" + aktif_kullanici + "", CommandType.Text);
            }
        }

        private void checkEdit2_CheckedChanged(object sender, EventArgs e)
        {
            if (checkEdit2.Checked == true)
            {
                sorgu = "SELECT tarih AS [TARİH], versiyon  AS  [  VERSİYON NO  ]  from TK_VERSIYON_BILGILERI  GROUP BY versiyon ORDER BY  versiyon  ";
                _1_dgv_guncelle();
            }
            if (checkEdit2.Checked == false)
            {
                sorgu = sorgu_ilk;
                _1_dgv_guncelle();
            }
        }

        private void gridView1_Click(object sender, EventArgs e)
        {
            int index1 = gridView1.FocusedRowHandle;
          secilen_versiyon=  "" + gridView1.GetRowCellValue(index1, "  VERSİYON NO  ").ToString() + "";
          _2_dgv_guncelle();

        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
             
        }
    }
}